#ifndef UTILITY_HPP
#define UTILITY_HPP

#include <QFile>
#include <QDebug>

class utility
{
public:
    static QString ReadFile(const QString &filePath)
    {
        QFile file(filePath);
        if(!file.open(QIODevice::ReadOnly)){
            qWarning() << "ReadFile: open file failed";
        }

        QTextStream textStream(&file);
        textStream.setCodec("UTF-8"); // 设置编码为 UTF-8
        QString style = textStream.readAll();
        file.close();

        return style;
    }

     static void WriteFile(const QString &filePath,const QString &text)
    {
        QFile file(filePath);
        if(!file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)){
            qWarning() << "WriteFile: open file failed";
        }

        QTextStream textStream(&file);
        textStream.setCodec("UTF-8"); // 设置编码为 UTF-8
        textStream << text;
        file.close();

    }
};





#endif
